package org.birrap.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "USUARIOS_T")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsuariosT.findAll", query = "SELECT u FROM UsuariosT u"),
    @NamedQuery(name = "UsuariosT.findByCorreo", query = "SELECT u FROM UsuariosT u WHERE u.correo = :correo"),
    @NamedQuery(name = "UsuariosT.findByNombre", query = "SELECT u FROM UsuariosT u WHERE u.nombre = :nombre"),
    @NamedQuery(name = "UsuariosT.findByApellidos", query = "SELECT u FROM UsuariosT u WHERE u.apellidos = :apellidos"),
    @NamedQuery(name = "UsuariosT.findByPassword", query = "SELECT u FROM UsuariosT u WHERE u.password = :password"),
    @NamedQuery(name = "UsuariosT.findByCorreoAndPassword",query = "SELECT u FROM UsuariosT u WHERE u.correo = :correo AND u.password = :password")})
public class UsuariosT implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "usuariosT")
    private Collection<BaresUsuarioT> baresUsuarioTCollection;
    @Size(max = 30)
    @Column(name = "TWITTER")
    private String twitter;
    @Size(max = 30)
    @Column(name = "FACEBOOK")
    private String facebook;
    @Size(max = 30)
    @Column(name = "TWITTER_PASS")
    private String twitterPass;
    @Size(max = 30)
    @Column(name = "FACEBOOK_PASS")
    private String facebookPass;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
             message="El correo no es correcto")
    @NotNull
    @Size(max = 30, message="El tamaño máximo del correo es de 30")
    @Column(name = "CORREO")
    private String correo;
    @Basic(optional = false)
    @NotNull
    @Size(max = 30, message="El tamaño máximo del nombre es 30")
    @Column(name = "NOMBRE")
    private String nombre;
    @Basic(optional = false)
    @NotNull
    @Size(max = 50, message="El tamaño máximo de los apellidos es 50")
    @Column(name = "APELLIDOS")
    private String apellidos;
    @Basic(optional = false)
    @NotNull
    @Size(max = 20, message="El tamaño máximo del password es 20")
    @Column(name = "PASSWORD")
    private String password;
    @JoinColumn(name = "ID_ROL", referencedColumnName = "ID_ROL")
    @ManyToOne(optional = false)
    private RolesT idRol;

    public UsuariosT() {
    }

    public UsuariosT(String correo) {
        this.correo = correo;
    }

    public UsuariosT(String correo, String nombre, String apellidos, String password) {
        this.correo = correo;
        this.nombre = nombre;
        this.apellidos = apellidos;
        this.password = password;
    }

    public String getCorreo() {
        return correo;
    }

    public void setCorreo(String correo) {
        this.correo = correo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getApellidos() {
        return apellidos;
    }

    public void setApellidos(String apellidos) {
        this.apellidos = apellidos;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public RolesT getIdRol() {
        return idRol;
    }

    public void setIdRol(RolesT idRol) {
        this.idRol = idRol;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (correo != null ? correo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsuariosT)) {
            return false;
        }
        UsuariosT other = (UsuariosT) object;
        if ((this.correo == null && other.correo != null) || (this.correo != null && !this.correo.equals(other.correo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.birrap.entities.UsuariosT[ correo=" + correo + " ]";
    }

    public String getTwitter() {
        return twitter;
    }

    public void setTwitter(String twitter) {
        this.twitter = twitter;
    }

    public String getFacebook() {
        return facebook;
    }

    public void setFacebook(String facebook) {
        this.facebook = facebook;
    }

    public String getTwitterPass() {
        return twitterPass;
    }

    public void setTwitterPass(String twitterPass) {
        this.twitterPass = twitterPass;
    }

    public String getFacebookPass() {
        return facebookPass;
    }

    public void setFacebookPass(String facebookPass) {
        this.facebookPass = facebookPass;
    }

    @XmlTransient
    public Collection<BaresUsuarioT> getBaresUsuarioTCollection() {
        return baresUsuarioTCollection;
    }

    public void setBaresUsuarioTCollection(Collection<BaresUsuarioT> baresUsuarioTCollection) {
        this.baresUsuarioTCollection = baresUsuarioTCollection;
    }
    
}
